
#include <variant>
// A helper to create overloaded function objects
template <typename... Fs>
struct overloaded : Fs... { using Fs::operator()...; };

template <typename... Fs> overloaded(Fs...) -> overloaded<Fs...>;
class tennis_t {
    enum class points {
        love,
        fifteen,
        thirty
    };
    enum class player {
        player_1,
        player_2
    };
    struct normal_scoring {
        points player_1_points;
        points player_2_points;
    };
    struct forty_scoring {
        player leading_player;
        points other_player_scores;
    };
    struct deuce{};
    struct advantage {
        player player_with_advantage;
    };
    std::variant<normal_scoring, forty_scoring, deuce, advantage> m_state;

    void point_for(player which_player)
    {
        std::visit(
            overloaded {
                [&]( const normal_scoring &state) {
                    //增加得分，或者切换状态
                },
                [&](const forty_scoring &state) {
                    //玩家胜，或切换到平局状态
                },
                [&](const deuce &state) {
                    //切换到占先状态
                },
                [&](const advantage &state) {
                    //玩家胜，或者回到平局状态
                }
            },
            m_state
        );
    }
};

int main(int argc, char *argv[])
{
    
}
